<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>2016春夏审样会评审投票系统</title>

<meta name="description" content="User login page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/bootstrap.min.css"
	rel="stylesheet" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome.min.css" />

<!--[if IE 7]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

<!-- page specific plugin styles -->

<!-- fonts -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-fonts.css" />

<!-- ace styles -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-rtl.min.css" />

<!--[if lte IE 8]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

<!--[if lt IE 9]>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/html5shiv.js"></script>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/respond.min.js"></script>
		<![endif]-->
<style type="text/css">


.table td {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	vertical-align: middle;
	text-align: center;
	
	
}
.tdClass {
	color: red;
	
}
</style>
</head>

<body>
<div class="container-fluid">
  <div class="row">
  	<div class="col-xs-12">
	    <table class="table table-striped table-bordered ">
	    	<tr>
	    		<td colspan="15"><h3>2016春夏审样会评审投票</h3>${sessionScope.userSession.sysUser.nickName }[${sessionScope.userSession.sysUser.company }]</td>
	    	</tr>
	    	<tr>
	    		<td >主题</td>
	    		<td colspan="6" >
								<select class="form-control" id="jsubject">
									<option value="">全部</option>
								</select>
				</td>
	    		<td colspan="8" rowspan="2" style="text-align: left;">
	    			评审投票说明：<br/>
	    			1、选择商品短码进行投票;<br/>
					2、修改时选择商品短码进行修改;<br/>
					3、所有产品属性为必选项;<br/>
					4、每件商品都要进行选择或者放弃;<br/>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td >品类</td>
	    		<td colspan="6" >
								<select class="form-control" id="jclass">
									<option value="">全部</option>
								</select>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td >短码</td>
	    		<td colspan="14">
	    			<div class="input-group">
						<span class="input-group-btn">
							<input type="text" id="short_code" class="form-control search-query" placeholder="请输入短码" />
							<button type="button" class="btn btn-purple btn-sm" id="btn_search">
								查找
								<i class="icon-search icon-on-right bigger-110"></i>
							</button>
							&nbsp;&nbsp;&nbsp;&nbsp;	
							<a class="btn btn-purple btn-sm" id="btn_downloadStat" href="#" >
								导出
								<i class="icon-download-alt icon-on-right bigger-110"></i>
							</a>
						</span>
					</div>
				</td>
	    	</tr>
	    	<tr>
	    		<td rowspan="2">序号</td>
	    		<td rowspan="2">短码</td>
	    		<td rowspan="2">投票票数</td>
	    		<td colspan="4">投票票数</td>
	    		<td rowspan="2">放弃票数</td>
				<td rowspan="2">投票占比</td>
				<td colspan="6">产品属性</td>
	    	</tr>
	    	<tr>
	    		<td>南区</td>
	    		<td>中区</td>
	    		<td>北区</td>
	    		<td>总部</td>
	    		<td>版型</td>
	    		<td>价格</td>
	    		<td>款式</td>
	    		<td>颜色</td>
	    		<td>面料</td>
	    		<td>总计</td>
	    	</tr>
	    	<tbody id="statView">
	    	
	    	</tbody>
	    </table>
    </div>
  </div>
</div>
<form action="${pageContext.request.contextPath}/admin/joeoneCode/downloadStat.do" id="hidden_form">
	<input type="hidden" name="jclassName" id="jclassName" />
	<input type="hidden" name="jclassId" id="jclassId"/>
	<input type="hidden" name="jsubjectName" id="jsubjectName"/>
	<input type="hidden" name="jsubjectId" id="jsubjectId"/>
</form>
	<!-- basic scripts -->

	<!--[if !IE]> -->

	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-2.0.3.min.js'>"
								+ "<"+"/script>");
	</script>

	<!-- <![endif]-->

	<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>


	<script type="text/javascript">
	function fn_getSubject() {
		var data = new Object();
		data['docStatus'] = "10";
		data['pageNo'] = "1";
		data['pageSize'] = "10";
		$.ajax({
					url : "${pageContext.request.contextPath}/admin/joeoneSubject/list.do",
					async : true,
					dataType : 'json',
					type : 'GET',
					data : data,
					success : function(data, textStatus) {
						$.each(data.data.listData, function(i, item) {
							$("#jsubject").append("<option value='"+item.docId+"'>"+item.docSubject+"</option>");
						}); 
					},
					error : function(jqXHR, textStatus, errorThrown) {
						var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
						if(sessionstatus == "timeout"){
							alert("[timeout]您登陆已经超时，请重新登陆!");
							var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
							window.location.href  = req_address;
						}
					}

		});
			
		

	}
		function fn_getClass() {
			var data = new Object();
			data['docStatus'] = "10";
			data['pageNo'] = "1";
			data['pageSize'] = "30";
			$.ajax({
						url : "${pageContext.request.contextPath}/admin/joeoneClass/list.do",
						async : true,
						dataType : 'json',
						type : 'GET',
						data : data,
						success : function(data, textStatus) {
							$.each(data.data.listData, function(i, item) {
								$("#jclass").append("<option value='"+item.docId+"'>"+item.docSubject+"</option>");
							}); 
						},
						error : function(jqXHR, textStatus, errorThrown) {
							var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
							if(sessionstatus == "timeout"){
								alert("[timeout]您登陆已经超时，请重新登陆!");
								var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
								window.location.href  = req_address;
							}
						}
	
			});
				
			

		}
		
		function fn_search() {
			var jsubject = $('#jsubject').val();
			var jclass = $('#jclass').val();
			var jcode = $('#short_code').val();
			
			var data = new Object();
			data['jsubjectId'] = jsubject;
			data['jclassId'] = jclass;
			data['jcode'] = jcode;
			
			$.ajax({
						url : "${pageContext.request.contextPath}/admin/joeoneCode/viewStat.do",
						async : true,
						dataType : 'json',
						type : 'GET',
						data : data,
						success : function(data, textStatus) {
							var ghNum = data.data.ghNum;
							var trStr = "";
							$.each(data.data.listData, function(i, item) {
								trStr += "<tr>";
								
								if(i+1 <= ghNum){
									trStr += "<td class='tdClass'>";
								}else{
									trStr += "  <td>";
								}
								
								
                                
                                trStr += (i+1);
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.jcode;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.c1;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.nq;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.zq;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.bq;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.zb;
                                trStr += "  </td>";
                                
                                trStr += "  <td>";
                                trStr += item.c2;
                                trStr += "  </td>";
                                
                                var tpzb = parseFloat(item.tpzb*100).toFixed(1);
                                if(item.tpzb < 0.5){
                                	trStr += "  <td class='tdClass'>";
                                }else{
                                	trStr += "  <td>";
                                }
                                
                                trStr += tpzb+"%";
                                trStr += "  </td>";
                                
                                var bx = parseFloat(item.bx).toFixed(1);
                                trStr += "  <td>";
                                trStr += bx;
                                trStr += "  </td>";
                                
                                var jg = parseFloat(item.jg).toFixed(1);
                                trStr += "  <td>";
                                trStr += jg;
                                trStr += "  </td>";
                                
                                var ks = parseFloat(item.ks).toFixed(1);
                                trStr += "  <td>";
                                trStr += ks;
                                trStr += "  </td>";
                                
                                var ys = parseFloat(item.ys).toFixed(1);
                                trStr += "  <td>";
                                trStr += ys;
                                trStr += "  </td>";
                                
                                var ml = parseFloat(item.ml).toFixed(1);
                                trStr += "  <td>";
                                trStr += ml;
                                trStr += "  </td>";


                                
                                var zj = parseFloat(item.zj).toFixed(1);
                                trStr += "  <td>";
                                trStr += zj;
                                trStr += "  </td>";
                                
                                trStr += "</tr>";
							}); 
							$("#statView").html(trStr)
						},
						error : function(jqXHR, textStatus, errorThrown) {
							var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
							if(sessionstatus == "timeout"){
								alert("[timeout]您登陆已经超时，请重新登陆!");
								var req_address = "${pageContext.request.contextPath}/joeone/ipad/index.jsp";
								window.location.href  = req_address;
							}
						}
	
			});
		}
		function fn_downloadStat() {
			var jsubjectId = $('#jsubject').val();
			$("#jsubjectId").val(jsubjectId);
			var jsubjectName = $("#jsubject").find("option:selected").text();
			$("#jsubjectName").val(jsubjectName);

			var jclassId = $('#jclass').val();
			$("#jclassId").val(jclassId);
			var jclassName = $("#jclass").find("option:selected").text();
			$("#jclassName").val(jclassName);
			
			var jcode = $('#short_code').val();
			$("#jcode").val(jcode);
			
			$("#hidden_form").submit();
			
		}
		function fn_downloadStat_test() {
			var jsubject = $('#jsubject').val();
			var jclass = $('#jclass').val();
			var data = new Object();
			data['jsubjectId'] = jsubject;
			data['jclassId'] = jclass;
			
			var req_address = "${pageContext.request.contextPath}/admin/joeoneCode/downloadStat.do?jsubjectId="+jsubject+"&jclassId="+jclass
			+"&jsubjectName="+$("#jsubject").find("option:selected").text()
			+"&jclassName="+$("#jclass").find("option:selected").text();
		
			window.location.href  = req_address;
			
		}
		$(document).ready(function() {
			fn_getSubject();
			fn_getClass();
			$("#btn_search").bind("click", fn_search);
			$("#btn_downloadStat").bind("click", fn_downloadStat);

		});
	</script>

</body>
</html>